﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MESMian.EntityMapping
{
    public class StoreCategoriesMapping : IEntityTypeConfiguration<StoreCategories>
    {
        public void Configure(EntityTypeBuilder<StoreCategories> builder)
        {
            builder.ToTable("StoreCategories");
            builder.HasKey(p=>p.StoreCategoryId);
            builder.Property(p => p.StoreCategoryId)
                .HasComment("仓库类型主键，自动编号");

            builder.Property(p => p.StoreCategoryName)
                .IsRequired()
                .HasColumnType("varchar(30)")
                .HasComment("仓库类型名称，不能重复");

            builder.Property(p=>p.Status)
                .IsRequired()
                .HasDefaultValue(0)
                .HasColumnType("int");

            builder.Property(p => p.CreateUserId)
                .HasColumnType("int")
                .IsRequired();

            builder.Property(p => p.CreateTime)
                .HasColumnType("datetime")
                .HasDefaultValueSql("GETDATE()")
                .IsRequired();

            builder.Property(p => p.LastUpdateUserId)
                .HasColumnType("int");

            builder.Property(p => p.LastUpdateTime)
                .HasColumnType("datetime");
                
            
        }
    }
}
